In regards to the prior art and this invention, certain terms of art will be used and are summarized hereinafter. A file in a computer system is a logical grouping of contiguous information identified with a name. A compiler is a program that translates a source code file into an object code file that contains machine instructions and additional symbolic information. In order to produce an executable file, the object code file output from the compiler requires modifications. A linker (also referred to as a "link editor") is a program that produces executable files from one or more files of non-executable object code. The executable file can be loaded and executed directly on the computer. The primary purpose of linkers is to resolve references to data or addresses in an object code file that are not able to be resolved by the compiler from the information contained in the source code file.
A compiled procedure is a block of executable code with a start address and is derived from a logical sequence of statements in a source code file. A program is a procedure with a start address that is recognized by the operating system. Execution of a procedure in the executable file is initiated by changing the value of the computer's program counter to be equal to the start address. At a higher level, in the source code file, this is often accomplished by means of a procedure call. In certain software systems, a plurality of source code compilers are provided for translating from a variety of source codes (e.g., BASIC, Ada, FORTRAN, C, etc.) to a common object code file format.
Compilers convert procedures in a source code file to an object code file representation that contains discrete blocks of machine instructions for each procedure in the source file as well as additional information that is symbolic in nature. The symbolic information is added to the object code file by the compiler because the compiler is unable to obtain all of the information required to generate the correct object code machine instructions from the source code file. The linker uses the symbolic information to modify machine instructions in the object code file and thus creates an executable file. This process is referred to as address fixup.
In many compilers, tables are constructed at compile-time that are meant for use when an exception (error) condition occurs. At link-time, such tables, along with other information, are added to the executable file. The resulting executable file is then able to be loaded and executed.
One such table is a line number table which is built during compile-time and includes a pair of numeric values for each line in the source code file. The first numeric value is a source code line number and the second numeric value is the offset of the first machine instruction in the object code file that results from the translation of that source code line into machine instructions. Thus, a line number table for a procedure associates a range of machine instruction offsets with a corresponding source code line in that source code file.
If an exception occurs during execution of an executable file, the block of machine instructions in which the exception occurred can be determined by reference to the line number table for that block of instructions (the compiled procedure). The information relating the machine instruction offset to the source code file line number in the line number table is used to determine the line number in the source file that was responsible for generating the machine instruction at which the exception occurred. Reference to that source code file line number assists the system user in troubleshooting the cause of the exception. The information in the line number table also permits recovery of execution at the machine instruction that corresponds to either the same source line as or the source line subsequent to the source line in which the exception occurred.
Line number tables in the prior art have employed one of two methods. The first method was to allocate a sufficient number of bytes for each entry in the line number table to accommodate the largest source code line number and a sufficient number of bytes to accommodate the largest machine instruction offset. As a result, line number tables using this method have heretofore consumed considerable space in the executable file. The second method was to pack the table by using a smaller number of bytes that would accommodate most, but not all of the cases. The disadvantage of this approach is that it adds complexity to the tables and the traversal method, in that there has to be some special value to indicate the special cases where the data will not fit in the table, and the traversal method has to handle this special case.
In the past, linkers did not change the number or sequence of machine instructions in object code files produced by the compilers. Thus, machine instruction offsets calculated during compile-time were the final machine instruction offsets in the executable file. Recently, however, linkers have become more sophisticated and have the ability to modify or eliminate machine instructions from the object code file that is generated by the compiler. Under such conditions, if line number tables are generated during compile-time, they must be updated to take into account such link-time modifications. This requires both complex "bookkeeping" of address modifications and consumes considerable processing time.
Accordingly, it is an object of this invention to provide a compiler and linker software system wherein line number tables need not be modified once they are first produced.
It is still another object of this invention to provide a line number table which occupies less storage than heretofore.
It is still another object of this invention to provide a system that determines a line in a source code file that generates a given machine instruction in an executable file and also identifies a file name and procedure name within which the source code line resides.